﻿function fnUserLogin() {
    var userid = $('#txtUsername').val();
    var password = $('#txtPassword').val();
    //alert(userid + " " + password);
    if (userid != '' && password != '') {
        var params = { "usder": userid, "pass": password }
        var containerDIV = $('.adminColorButton');
        var opts = { 'isLoadingGif': true, 'container': containerDIV };
        MakeJAjaxCall("../_services/userLogin.ashx", params, 'html', fnLoginSuccess, '', '', opts);
    }
    else {
        var msg = "Please enter your username and password!";
        var opts = { 'AlertText': msg, 'OKTxt': 'OK', 'CancelTxt': 'No', 'okClick': loadDummy, 'cancelClick': loadDummy, 'reqCancel': false };
        genAlertPOPUP(opts);
    }
}
function fnLoginSuccess(response) {
    if (response == "y") {
        window.location.href = "../../pages/dashboard.aspx";
    }
    else {
        var msg = "Username/Password Incorrect. Please try again!";
        var opts = { 'AlertText': msg, 'OKTxt': 'OK', 'CancelTxt': 'No', 'okClick': loadDummy, 'cancelClick': loadDummy, 'reqCancel': false };
        genAlertPOPUP(opts);
    }
}
function loginValidationFail() {
    var msg = "Please enter your username and password!";
    var opts = { 'AlertText': msg, 'OKTxt': 'OK', 'CancelTxt': 'No', 'okClick': loadDummy, 'cancelClick': loadDummy, 'reqCancel': false };
    genAlertPOPUP(opts);
}
function loginFailed() {
    var msg = "Username/Password Incorrect. Please try again!";
    var opts = { 'AlertText': msg, 'OKTxt': 'OK', 'CancelTxt': 'No', 'okClick': loadDummy, 'cancelClick': loadDummy, 'reqCancel': false };
    genAlertPOPUP(opts);
}
function loadDummy() {
}
function fnLoginURL() {
    window.location = "login.aspx";
}
function fnLogoutURL() {
    window.location = "../../auth/logout.aspx";
}